package com.yuer.rpc.thread;


import java.util.concurrent.*;

/**
 *  实现Callable接口，重写call()方法
 *  创建多线程:方法三
 */
public class MyThread3 implements Callable<String>{


    public static void main(String[] args) {
        ExecutorService threadPool= Executors.newSingleThreadExecutor();//启动多线程

        Future future= threadPool.submit(new MyThread3());
        try{
            System.out.println("waiting thread to finish"+future.isDone());
            System.out.println(future.get());
            System.out.println("waiting thread to finish"+future.isDone());
        }catch(Exception e){
            e.printStackTrace();
        }
    }

    @Override
    public String call() throws Exception {
        // TODO Auto-generated method stub
        for (int i = 0; i < 10; i++) {
            System.out.println("123456已欧派 ");
            TimeUnit.SECONDS.sleep(1);
        }
        return "创建多线程方法三";
    }
}